package com.ddwl.wallet.controller;

import com.ddwl.common.annotation.Auth;
import com.ddwl.common.constant.BaseEnum;
import com.ddwl.common.constant.DistTypeEnum;
import com.ddwl.common.controller.BaseController;
import com.ddwl.schema.bo.base.PageBo;
import com.ddwl.schema.bo.order.QueryUserDistOrderBo;
import com.ddwl.schema.vo.base.PageVo;
import com.ddwl.schema.vo.base.RestVo;
import com.ddwl.schema.vo.wallet.DistOrderVo;
import com.ddwl.wallet.service.DistOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * 类ShopDistOrderController.java的实现描述：TODO
 *
 * @author zach
 * @Date :2020-12-04 17:35.
 */
@Slf4j
@Api(tags = "店铺商户分销订单接口")
@RequestMapping("/shop")
@RestController
public class ShopDistOrderController extends BaseController {

    @Resource
    private DistOrderService distOrderService;

    @PostMapping("/distPage")
    @Auth(product = {BaseEnum.ProductEnum.SHOP_CONSOLE})
    @ApiOperation("店铺查询分销订单")
    public RestVo<PageVo<DistOrderVo>> distPage(@RequestBody PageBo<QueryUserDistOrderBo> pageBo) {
        if (pageBo.getParam() == null) {
            pageBo.setParam(new QueryUserDistOrderBo());
        }
        pageBo.getParam().setDistUserId(getUserId());
        //店铺管理后台佣金默认过滤店铺自己的订单佣金的查询
        pageBo.getParam().setNotInDistType(Arrays.asList(DistTypeEnum.SHOP.getType()));
        return RestVo.ok(distOrderService.getDistPageForConsole(pageBo));
    }


}
